var t = getApp();

Page({
    data: {
        commentType: 0,
        dynamicId: 0,
        dynamicCommentId: 0,
        dynamicZanId: 0,
        content: ""
    },
    bindContentInput: function(t) {
        this.setData({
            content: t.detail.value
        });
    },
    bindSubmitTap: function() {
        "" == this.data.content && t.util.showToast("请输入评论内容");
        var n = this, a = t.url.hunyuCycleComment, e = {
            content: n.data.content
        };
        0 == n.data.commentType ? (a = t.url.hunyuCycleComment, e.dynamicId = n.data.dynamicId) : 1 == n.data.commentType ? (a = t.url.hunyuCycleCommentReply, 
        e.dynamicCommentId = n.data.dynamicCommentId) : 2 == n.data.commentType && (a = t.url.hunyuCycleCommentZan, 
        e.dynamicZanId = n.data.dynamicZanId), t.network.post({
            url: a,
            params: e,
            before: function() {
                wx.showLoading({
                    title: "提交数据"
                });
            },
            success: function(n) {
                if (wx.hideLoading(), 1 == n.data.result) {
                    t.util.showToast(n.data.message);
                    var a = getCurrentPages();
                    a.length > 1 && a[a.length - 2].loadCommentListData(!0), wx.navigateBack();
                } else wx.hideLoading(), t.util.showToast(n.data.message);
            },
            fail: function() {
                wx.hideLoading(), t.util.showToast("提交数据失败");
            },
            complete: function() {}
        });
    },
    onLoad: function(n) {
        t.log(n), this.setData({
            commentType: n.commentType,
            dynamicId: 0 == n.commentType ? n.dynamicId : 0,
            dynamicCommentId: 1 == n.commentType ? n.dynamicCommentId : 0,
            dynamicZanId: 2 == n.commentType ? n.dynamicZanId : 0
        }), 0 == this.data.commentType ? wx.setNavigationBarTitle({
            title: "写评论"
        }) : 1 == this.data.commentType ? wx.setNavigationBarTitle({
            title: "写回复"
        }) : 2 == this.data.commentType && wx.setNavigationBarTitle({
            title: "赞回复"
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});